<%@ page import="dao.ProductDao" %>
<%@ page import="domain.Product" %>
<%--
  Created by IntelliJ IDEA.
  User: ThinkPad
  Date: 2021/12/25
  Time: 10:46
  To change this template use File | Settings | File Templates.
--%>
<%-- 请勿直接访问此页面 --%>
<%@ page contentType="text/html;charset=UTF-8"%>
<html>
<head>
    <title>后台-删除商品反馈</title>
</head>
<body>
<%@include file="headForRoot.jsp"%>
<%
    String deleteString = request.getParameter("delete");
    if (deleteString==null){
%>
<script>
    alert("您没有指定要删除的产品。是怎么导航到此页面的？");
    window.location="manage.jsp";
</script>
<%
    }else{
        ProductDao dao = new ProductDao();
        try {
            int delete = Integer.parseInt(deleteString);
            Product product = dao.search(delete);
            if (product!=null){
%>
<div style="text-align: center">
    <br />以下商品信息：<br /><br /><br />
    <table style="margin-left: 35%">
        <tr>
            <td style="width: 100px">商品名：</td>
            <td><%=product.getName()%></td>
        </tr>
        <tr>
            <td>商品库存：</td>
            <td><%=product.getCount()%></td>
        </tr>
        <tr>
            <td>商品价格：</td>
            <td><%=product.getPrice()%></td>
        </tr>
        <tr>
            <td>商品描述：</td>
            <td><%=product.getDescription()%></td>
        </tr>
    </table>
    <%
            }
            if (dao.delete(delete)){
    %>
    <br />已从数据库中删除<br />
    五秒后将为您重新跳转至后台管理页面……
</div>
<%
                response.setHeader("refresh","5;URL=manage.jsp");
            }
        }catch (NumberFormatException e){
            e.printStackTrace();
        }
    }
%>
<%@include file="tail.jsp"%>
</body>
</html>
